'use strict'
function getSignature (obj, secret) {
  var crypto = require('crypto');

  // 构造kv数组
  let arr = []
  for (let key in obj) {
    var kv = '';
    kv = String(key) + '=' + obj[key]
    arr.push(kv)
  }

  // array按首字母排序
  arr.sort()
  //  action + token + arr.join() + secret
  var str = arr.join('') + secret;
  // to md5
  var md5 = crypto.createHash('md5');
  md5.update(str, 'utf8');
  return md5.digest('hex').toUpperCase()
}

module.exports.getSignature = getSignature;